<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <title>选择经典BTC算力包</title>
    <link rel="stylesheet" href="../../css/reset.css" />
    <style>
        body {
            width: 100%;
            background-color: #F8F8F8;
            font-family: Helvetica;
            color: #333333;
            font-size: 0.28rem;
            /* font-family: "pingfangSC", serif; */
            font-family: PingFang SC;
        }

        .stepone {
            width: 6.9rem;
            height: 2.12rem;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: center;
            padding: 0 0.3rem;
            box-sizing: border-box;
            margin-top: 0.3rem;
            background-color: #fff;
            margin-left: calc((100% - 6.9rem) / 2);
            border-radius: 0.12rem;
            margin-bottom: 0.2rem;
        }

        .stepone>b {
            width: 100%;
            font-size: 0.3rem;
        }

        .stepone .payMethod {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: flex-start;
            margin: 0.2rem 0;
        }

        .stepone .payMethod span {
            display: flex;
            display: -webkit-flex;
            width: 1.5rem;
            height: 0.48rem;
            background: rgba(255, 210, 3, 1);
            border-radius: 0.06rem;
            align-items: center;
            justify-content: center;
            color: #383838;
            margin-right: 0.2rem;
            font-size: 0.23rem;
        }

        .stepone .payMethod .nochicked {
            background: #F5F5F5;
            color: #999999;
        }

        .quotaNum {
            width: 6.9rem;
            height: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-between;
            color: rgba(153, 153, 153, 1);
            padding: 0.22rem 0.3rem;
            font-size: 0.26rem;
            margin-left: calc((100% - 6.9rem) / 2);
            background-color: #fff;
            box-sizing: border-box;
            border-radius: 0.1rem;
        }

        .quotaNum span {
            color: #F67311;
        }

        .quotaNum b {
            font-weight: normal;
        }

        .couponListBox {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            justify-content: flex-start;
            padding: 0 0.3rem;
            box-sizing: border-box;
            margin-top: 0.1rem;
        }

        .couponListBox>li {
            margin-bottom: 0.2rem;
            border-radius: 0.1rem;
            overflow: hidden;
        }

        .couponListBox>li>div {
            display: block;
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: space-between;
            background-color: #fff;
            box-sizing: border-box;
            padding: 0.27rem 0;
        }

        input[name="machineList"] {
            width: 0.36rem;
            height: 0.36rem;
            background-color: #fff;
            -webkit-appearance: none;
            border: 1px solid #c9c9c9;
            outline: none;
            border-radius: 50%;
        }

        input[name="machineList"]:checked {
            width: 0.36rem;
            height: 0.36rem;
            background: url("../../image/iconxuangousuanlibao.png")no-repeat center;
            background-size: 100% 100%;
        }

        .machineName {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 0.24rem;
            box-sizing: border-box;
            margin-bottom: 0.18rem;
        }

        .machineName p {
            width: auto;
            height: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
        }

        .machineName p:last-of-type {
            width: 1.16rem;
            height: 0.42rem;
            background: rgba(255, 255, 255, 1);
            border: 1px solid rgba(220, 220, 220, 1);
            border-radius: 0.22rem;
            font-size: 0.22rem;
            font-weight: 500;
            color: rgba(153, 153, 153, 1);
            justify-content: center;
        }

        .machineName .machineText {
            font-size: 0.28rem;
            font-weight: 500;
            color: rgba(38, 38, 38, 1);
            margin-left: 0.1rem;
        }

        .machineName p label {
            display: flex;
            display: -webkit-flex;
            align-items: center;
        }

        .machineDetail {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: flex-start;
            box-sizing: border-box;
            padding: 0 0.24rem;
        }

        .machineDetail>li {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 0.2rem;
            font-size: 0.24rem;
            color: #999999;
        }

        .machineDetail>li>p>span:last-of-type {
            color: #595959;
        }

        .machineDetail>li>p:last-of-type {
            width: 2.4rem;
        }

        .machineDetail>li>p span:first-of-type {
            margin-right: 0.1rem;
        }

        .changeChoose {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 0.24rem;
            box-sizing: border-box;
            border-top: 1px solid #EEEEEE;
            padding-top: 0.18rem;
        }

        .changeChoose div {
            width: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: flex-end;
        }

        .chooseNum {
            width: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: center;
        }

        .chooseNum span {
            display: block;
            width: 0.44rem;
            height: 0.44rem;
            background: rgba(238, 238, 238, 1);
            border-radius: 0.08rem;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: center;
            font-size: 0.26rem;
            color: #595959;
        }

        .chooseNum input {
            outline: none;
            border: none;
            display: block;
            width: 0.74rem;
            height: 0.4rem;
            background: rgba(238, 238, 238, 1);
            border-radius: 0.04rem;
            margin: 0 0.1rem;
            text-align: center;
            font-size: 0.28rem;
            color: #595959;
        }

        .changeChoose .moneyDischare {
            font-size: 0.2rem;
            color: #FF6E3C;
            margin-right: 0.18rem;
        }

        .changeChoose>p {
            font-size: 0.26rem;
            font-weight: 500;
            color: rgba(89, 89, 89, 1);
        }

        .fixedButtom {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            position: fixed;
            bottom: 0;
            left: 0;
        }

        .ipfsChangeText {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            background-color: #fff;
            border-radius: 0.25rem 0.25rem 0 0;
            overflow: hidden;
            padding-top: 0.3rem;
            border-bottom: 1px solid rgba(229, 229, 229, 1);
        }

        .ipfsChangeText li {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 0.3rem;
            box-sizing: border-box;
            margin-bottom: 0.2rem;
            font-size: 0.26rem;
            font-weight: 500;
            color: rgba(153, 153, 153, 1);
        }

        .ipfsChangeText li>p:last-of-type {
            color: #262626;
        }

        .ipfsChangeText li:first-of-type>p:last-of-type {
            color: #FF6E3C;
        }

        .submitMessage {
            width: 100%;
            height: 2rem;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            background-color: #fff;
            justify-content: center;
            padding: 0 0.3rem;
            box-sizing: border-box;
            font-size: 0.26rem;
            padding-bottom: 0.1rem;
        }

        .submitMessage>p {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: flex-end;
            margin-bottom: 0.3rem;
            color: rgba(153, 153, 153, 1);
        }

        .submitMessage>p:first-of-type img {
            width: 0.23rem;
            margin-left: 0.1rem;
        }

        input[name="chackArgee"] {
            width: 0.36rem;
            height: 0.36rem;
            background-color: #fff;
            -webkit-appearance: none;
            border: 1px solid #c9c9c9;
            outline: none;
            border-radius: 2px;
            margin-right: .1rem;
        }

        input[name="chackArgee"]:checked {
            width: 0.36rem;
            height: 0.36rem;
            background: url("../../image/checked.png")no-repeat center;
            background-size: 100% 100%;
            border: none;
        }

        .boxStyele {
            display: flex;
            display: -webkit-flex;
            align-items: center;
        }

        .submitButton {
            height: 0.82rem;
            background: rgba(255, 210, 3, 1);
            border-radius: 0.16rem;
            outline: none;
            border: none;
            color: #282828;
            font-size: 0.28rem;
        }

        .notClick {
            background: #D0D0D0;
            color: #ffffff;
        }

        .rotatedeg {
            transform: rotate(0);
            -webkit-transform: rotate(0);
            transition: all .1s linear;
            -webkit-transition: all .1s linear;
        }

        .rotate {
            transform: rotate(180deg);
            transition: all .3s linear;
            -webkit-transform: rotate(180deg);
            -webkit-transtion: all .1s linear;
        }

        #aboutUsPage {
            font-family: PingFang SC;
            font-weight: 500;
            text-decoration: underline;
            color: rgba(255, 145, 3, 1);
        }

        .radios {
            height: 0.5rem;
            background: url("../../image/iconbasx.png") no-repeat left;
            background-size: 0.3rem 0.3rem;
            padding-left: 0.5rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 0.24rem;
        }

        #otcBlanceInput:checked+label {
            background: url("../../image/iconaaax.png") no-repeat left;
            background-size: 0.3rem 0.3rem;
        }

        .chooseBhpPower {
            width: 100%;
            height: auto;
            display: flex;
            display: -webkit-flex;
            align-items: center;
            justify-content: flex-end;
            padding: 0 0.3rem;
            box-sizing: border-box;
            color: rgba(137, 137, 137, 1);
        }

        .noListImg {
            width: 100%;
            display: flex;
            display: -webkit-flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            margin-top: 0.3rem;
        }
    </style>
</head>

<body>
    <div class="stepone">
        <b>
            下单时支付方式:
        </b>
        <p class="payMethod">
            <span data-coin="CNY">CNY支付</span>
            <span class="nochicked" data-coin="USDT">USDT支付</span>
        </p>
    </div>
    <!-- <p class="quotaNum" style="margin-top: 0.1rem;">
        <b>
            该支付方式置换额度为：<span class="replacementQuota">--T</span>
        </b>
        <a href="javascript:void(0)" id="aboutUsPage">额度说明</a>
    </p> -->
    <p class="chooseBhpPower">
        <input type="checkbox" name="sex" id="otcBlanceInput"
            style="border:0;background: none;width: 0;height: 0;opacity: 0;" class="radios">
        <label for="otcBlanceInput" class="radios">隐藏双挖合约包</label>
    </p>
    <div class="useCouponList">
        <ul class="couponListBox">

        </ul>
        <div class="noListImg" style="display: none;">
            <img src="../../image/nonedsdfx.png" style="width:2.23rem;margin-bottom: 0.1rem;">
            <span
                style="font-size:0.26rem;font-family:PingFang SC;font-weight:500;color:rgba(153,153,153,1);">暂无可置换合约包~</span>
        </div>
    </div>
    <div class="fixedButtom">
        <ul class="ipfsChangeText" style="display: none;">
            <li>
                <p>
                    金额
                </p>
                <p class="pageTatalMoney">
                    --
                </p>
            </li>
            <li>
                <p>
                    份额
                </p>
                <p class="pageTatalNum">
                    --
                </p>
            </li>
            <li>
                <p>
                    BTC算力
                </p>
                <p class="pageToatalPower">
                    --
                </p>
            </li>
            <li>
                <p>
                    BHP参配算力
                </p>
                <p class="pageTotalBhpower">
                    --
                </p>
            </li>
        </ul>
        <div class="submitMessage">
            <p class="chooseMessage">
                <span>
                    已选择信息
                </span>
                <img src="../../image/up.png" alt="" class="ratoteImg rotatedeg">
            </p>
            <button class="submitButton notClick">
                确认
            </button>
        </div>
    </div>
</body>
<script src="../../script/autosize.js"></script>
<script src="../../script/fastclick.js"></script>
<script src="../../script/jquery_three_two_one.js"></script>
<script src="../../script/dotmin.js"></script>
<script src="../../script/app.js"></script>
<script>
    apiready = function () {
        var app = new APP();
        var account = app.getAccount();
        var curpage = 1;//当前页
        var totalPage = 0;//总页数
        var paymentCurrencyCode = "CNY";//支付币种
        var maxChangeNum = 0;//最大置换额度
        var chooseNum = 0;//已选择的置换份额
        var chooseValueAdd = {
            chooseTotalBasePower: 0,//选择基础算力求和
            chooseTotalcouptingPowe: 0,//选择总算力求和
            bhpTotalPower: 0,//双挖总算力求和
            unitTotalMoney: 0,//总价格
            chooseNum: 0//选择的份数
        }
        var totalArrValue = {
            arrBasePower: 0,//基础算力
            arrcouponPower: 0,//总算力
            arrBhppower: 0,//bhppower
            unitPrice: 0,//单价
            chooseNum: 0,//选择的份数
            orderId: ""//订单ID
        }
        var chooseArrItem = [];//订单选择相关信息
        var storeObj = app.getSyncStorage("changeMachineStore");
        if (!storeObj) {
            app.setStorage("changeMachineStore", {
                chooseArrItem: [],
                paycurry: paymentCurrencyCode
            });
            storeObj = app.getSyncStorage("changeMachineStore");
        } else {
            chooseArrItem = JSON.parse(storeObj).chooseArrItem;
            paymentCurrencyCode = JSON.parse(storeObj).paycurry;
            if (paymentCurrencyCode == "USDT") {
                $(".payMethod span").addClass("nochicked");
                $(".payMethod").find("span:last-of-type").removeClass("nochicked");
            }
        }
        //清理数据
        function clearChoose() {
            chooseValueAdd = {
                chooseTotalBasePower: 0,//选择基础算力求和
                chooseTotalcouptingPowe: 0,//选择总算力求和
                bhpTotalPower: 0,//双挖总算力求和
                unitTotalMoney: 0,//总价格
                chooseNum: 0//选择的份数
            };
            chooseArrItem = [];
            $(".pageTatalMoney").text(0 + paymentCurrencyCode);
            $(".pageTatalNum").text(0 + "份");
            $(".pageToatalPower").text("0T(0T+0T)");
            $(".pageTotalBhpower").text(0 + "T");
        }
        function reloadNum() {
            $("input:checkbox[name=machineList]").each(function () {
                if ($(this).is(':checked')) {
                    var nameOptin = $(this).attr("data-nameOptin");
                    $("." + nameOptin).show();
                    totalArrValue = {
                        arrBasePower: $(this).attr("data-chooseBasepower"),
                        arrcouponPower: $(this).attr("data-chooseCouPower"),
                        arrBhppower: $(this).attr("data-chooseBhppower"),
                        unitPrice: $(this).attr("data-chooseUnitMoney"),
                        chooseNum: $(this).attr("data-chooseNumber"),
                        orderId: $(this).attr("data-orderId")
                    }
                    chooseArrItem.push(totalArrValue);
                } else {
                    var nameOptin = $(this).attr("data-nameOptin");
                    $("." + nameOptin).hide();
                }
            });
            for (var i = 0; i < chooseArrItem.length; i++) {
                chooseValueAdd.chooseTotalBasePower = app.accAdd(chooseValueAdd.chooseTotalBasePower, chooseArrItem[i].arrBasePower);
                chooseValueAdd.chooseTotalcouptingPowe = app.accAdd(chooseValueAdd.chooseTotalcouptingPowe, chooseArrItem[i].arrcouponPower);
                chooseValueAdd.bhpTotalPower = app.accAdd(chooseValueAdd.bhpTotalPower, chooseArrItem[i].arrBhppower);
                chooseValueAdd.unitTotalMoney = app.accAdd(chooseValueAdd.unitTotalMoney, chooseArrItem[i].unitPrice);
                chooseValueAdd.chooseNum = app.accAdd(chooseValueAdd.chooseNum, chooseArrItem[i].chooseNum);
            }
            $(".pageTatalMoney").text(chooseValueAdd.unitTotalMoney + paymentCurrencyCode);
            $(".pageTatalNum").text(chooseValueAdd.chooseNum + "份");
            var otherPower = app.numSub(chooseValueAdd.chooseTotalcouptingPowe, chooseValueAdd.chooseTotalBasePower);
            $(".pageToatalPower").text(chooseValueAdd.chooseTotalcouptingPowe + "T(" + chooseValueAdd.chooseTotalBasePower + "T+" + otherPower + "T)");
            $(".pageTotalBhpower").text(chooseValueAdd.bhpTotalPower + "T");
            if (chooseArrItem.length > 0) {
                $(".submitButton").removeClass("notClick");
                $(".ipfsChangeText").show();
            } else {
                $(".submitButton").addClass("notClick");
                $(".ipfsChangeText").hide();
            }
        }
        function getChooseAbout() {
            $("input:checkbox[name=machineList]").each(function () {
                if ($(this).is(':checked')) {
                    var nameOptin = $(this).attr("data-nameOptin");
                    $("." + nameOptin).show();
                    totalArrValue = {
                        arrBasePower: $(this).attr("data-chooseBasepower"),
                        arrcouponPower: $(this).attr("data-chooseCouPower"),
                        arrBhppower: $(this).attr("data-chooseBhppower"),
                        unitPrice: $(this).attr("data-chooseUnitMoney"),
                        chooseNum: $(this).attr("data-chooseNumber"),
                        orderId: $(this).attr("data-orderId")
                    }
                    chooseArrItem.push(totalArrValue);
                } else {
                    var nameOptin = $(this).attr("data-nameOptin");
                    $("." + nameOptin).hide();
                }
            });
            for (var i = 0; i < chooseArrItem.length; i++) {
                chooseValueAdd.chooseTotalBasePower = app.accAdd(chooseValueAdd.chooseTotalBasePower, chooseArrItem[i].arrBasePower);
                chooseValueAdd.chooseTotalcouptingPowe = app.accAdd(chooseValueAdd.chooseTotalcouptingPowe, chooseArrItem[i].arrcouponPower);
                chooseValueAdd.bhpTotalPower = app.accAdd(chooseValueAdd.bhpTotalPower, chooseArrItem[i].arrBhppower);
                chooseValueAdd.unitTotalMoney = app.accAdd(chooseValueAdd.unitTotalMoney, chooseArrItem[i].unitPrice);
                chooseValueAdd.chooseNum = app.accAdd(chooseValueAdd.chooseNum, chooseArrItem[i].chooseNum);
            }
            $(".pageTatalMoney").text(chooseValueAdd.unitTotalMoney + paymentCurrencyCode);
            $(".pageTatalNum").text(chooseValueAdd.chooseNum + "份");
            var otherPower = app.numSub(chooseValueAdd.chooseTotalcouptingPowe, chooseValueAdd.chooseTotalBasePower);
            $(".pageToatalPower").text(chooseValueAdd.chooseTotalcouptingPowe + "T(" + chooseValueAdd.chooseTotalBasePower + "T+" + otherPower + "T)");
            $(".pageTotalBhpower").text(chooseValueAdd.bhpTotalPower + "T");
            if (chooseArrItem.length > 0) {
                $(".submitButton").removeClass("notClick");
                $(".ipfsChangeText").show();
            } else {
                $(".submitButton").addClass("notClick");
                $(".ipfsChangeText").hide();
            }
            // console.log("---------------chooseValueAdd.chooseTotalBasePower" + chooseValueAdd.chooseTotalBasePower + "==max==" + maxChangeNum);
            // if (chooseValueAdd.chooseTotalBasePower > maxChangeNum) {
            //     // var thisInput = chooseArrItem[chooseArrItem.length - 1].orderId;
            //     // // console.log("------------" + chooseArrItem[chooseArrItem.length - 1].orderId);
            //     // // $(".couponListBox").find('input[data-orderId=' + thisInput + ']').attr("ckecked", false);
            //     // $("input:checkbox[name=machineList]").each(function () {
            //     //     if ($(this).attr("data-orderId") == thisInput) {
            //     //         $(this).prop("checked", false);
            //     //     }
            //     // });
            //     // clearChoose();
            //     // reloadNum();
            //     var param = {
            //         dtype: "dialog12",
            //         data: {
            //             title: "提示",
            //             text: "已选择份额超过可置换额度"
            //         }
            //     };
            //     app.dialog(param);
            // }
        }
        //置换BTC矿机列表
        function couponList(account, page, paymentCurrencyCode, isdown) {
            var isshowBhp = $("#otcBlanceInput").prop("checked");
            app.ajaxPro({
                url: "order/btc-replace-lists",
                values: {
                    token: account.token,
                    paymentCurrencyCode: paymentCurrencyCode,
                    displace: 1,
                    page: page,
                    isBhpPos: isshowBhp == true ? 0 : ""
                },
                openFlower: true
            }, function (ret) {
                if (ret.code == 200) {
                    var dataList = ret.data.lists;
                    totalPage = ret.data.totalPages;
                    // maxChangeNum = parseInt(ret.data.ReplacementQuota);
                    // $(".replacementQuota").text(maxChangeNum + "T");
                    dataList.map(function (item) {
                        item.curryName = paymentCurrencyCode;
                        item.totalBasePower = app.accMul(item.basePower, item.num);
                        item.totalComputingPower = app.accMul(item.computingPower, item.num);
                        item.chooseUnitMoney = item.productDeposit;//默认用户选择的单价
                        item.chooseBasepower = item.basePower;//默认用户选择基本算力
                        item.chooseCouPower = item.computingPower;//默认用户选择的总算力
                        item.chooseBhppower = item.bhpPower;//默认用户选择的单价
                        item.chooseNumber = 1;//默认用户选择的份数
                        if (chooseArrItem.length > 0) {
                            for (var i = 0; i < chooseArrItem.length; i++) {
                                var element = chooseArrItem[i];
                                if (element.orderId == item.orderId) {
                                    item.chooseUnitMoney = element.unitPrice;//默认用户选择的单价
                                    item.chooseBasepower = element.arrBasePower;//默认用户选择基本算力
                                    item.chooseCouPower = element.arrcouponPower;//默认用户选择的总算力
                                    item.chooseBhppower = element.arrBhppower;//默认用户选择的单价
                                    item.chooseNumber = element.chooseNum;//默认用户选择的份数
                                    item.checkedInput = true
                                }
                            }
                        }
                    })
                    if (chooseArrItem.length > 0) {
                        getChooseAbout();
                    }
                    var temp = doT.template($("#couponListLi").text());
                    if (isdown) {
                        $(".couponListBox").html(temp(dataList));
                    } else {
                        $(".couponListBox").append(temp(dataList));
                    }
                    if (page == 1 && dataList.length == 0) {
                        $(".noListImg").show();
                        $(".couponListBox").css("paddingBottom", 0);
                    } else {
                        $(".noListImg").hide();
                        $(".couponListBox").css("paddingBottom", "5.4rem");
                    }
                } else {
                    app.toast(ret.message);
                }
            })
        }
        couponList(account, curpage, paymentCurrencyCode, true);
        //切换支付币种
        $(".payMethod span").click(function () {
            $(this).removeClass("nochicked").siblings().addClass("nochicked");
            paymentCurrencyCode = $(this).attr("data-coin");
            app.setStorage("changeMachineStore", {
                chooseArrItem: [],
                paycurry: paymentCurrencyCode
            });
            clearChoose();
            $(".couponListBox").empty();
            totalPage = 0;
            curpage = 1;
            couponList(account, curpage, paymentCurrencyCode, true);
        });
        $("#otcBlanceInput").change(function () {
            app.setStorage("changeMachineStore", {
                chooseArrItem: [],
                paycurry: paymentCurrencyCode
            });
            clearChoose();
            $(".couponListBox").empty();
            totalPage = 0;
            curpage = 1;
            couponList(account, curpage, paymentCurrencyCode, true);
        })
        function setStroe(event, value) {
            // console.log("---------" + JSON.stringify(event) + "****" + value);
            event.attr("data-chooseBasepower", "");
            event.attr("data-chooseCouPower", "");
            event.attr("data-chooseBhppower", "");
            event.attr("data-chooseUnitMoney", "");
            event.attr("data-chooseNumber", "");
            var basePower = event.attr("data-basePower");
            var couputingPower = event.attr("data-couputingPower");
            var bhpPower = event.attr("data-bhpPower");
            var unitMoney = event.attr("data-unitMoney");
            // console.log("------------" + basePower + "*" + couputingPower + "**" + bhpPower + "*" + unitMoney)
            event.attr("data-chooseBasepower", app.accMul(basePower, value));
            event.attr("data-chooseCouPower", app.accMul(couputingPower, value));
            event.attr("data-chooseBhppower", app.accMul(bhpPower, value));
            event.attr("data-chooseUnitMoney", app.accMul(unitMoney, value));
            event.attr("data-chooseNumber", value);
        }
        //置换份额的加减
        $(".couponListBox").on("click", ".chooseNum span", function () {
            var typeClick = $(this).attr("data-type");
            var thisValue = $(this).parent().find("input").val();
            var maxchooseNum = $(this).attr("data-maxNum");
            if (typeClick == "disButton") {
                if (thisValue > 1) {
                    thisValue--;
                }
                $(this).parent().find("input").val(thisValue);
            } else {
                // console.log("-----------");
                var basePowerNew = $(this).attr("data-basePower");
                var thisValue = $(this).parent().find("input").val();
                // console.log("-------------最大值"+maxchooseNum);
                if (Number(thisValue) < Number(maxchooseNum)) {
                    thisValue++
                }
                // var disMax = app.numSub(maxChangeNum, chooseValueAdd.chooseTotalBasePower);//用户当前可选的值 置换额度 减去 已选择的额度 
                // var limitNum = app.numSub(maxchooseNum, thisValue);//该订单份额 减去 当前输入值
                // // console.log("*******" + disMax + "---" + limitNum + "max" + maxchooseNum + "******" + chooseValueAdd.chooseTotalBasePower + "----------" + thisValue + "basePwer" + basePowerNew);
                // if (Number(basePowerNew) > Number(disMax)) {
                //     // console.log("****111111111111111111***");
                //     return
                // }
                // // console.log("*******");
                // thisValue++;
                // if (thisValue > maxchooseNum) {
                //     thisValue--;
                // }
                // // console.log("*******" + disMax + "---" + limitNum + "max" + maxchooseNum + "******" + chooseValueAdd.chooseTotalBasePower + "----------" + thisValue);
                // if (disMax < app.accMul(limitNum, basePowerNew) && app.accMul(1, basePowerNew) < disMax) {
                //     // console.log("*******" + thisValue);
                //     var thisValue_1 = parseInt(disMax / basePowerNew);
                //     if (disMax <= 0 || thisValue_1 <= 0) {
                //         thisValue = 1;
                //     }
                // }
                // // console.log("*******" + disMax + "---" + limitNum + "max" + maxchooseNum);
                // if (disMax > app.accMul(limitNum, basePowerNew) && thisValue > maxchooseNum) {
                //     thisValue = maxchooseNum;
                // }
            }
            var inputName = $(this).attr("data-classInputName");
            $(this).parent().find("input").val(thisValue);
            setStroe($("." + inputName), thisValue);
            clearChoose();
            getChooseAbout();
        });
        //置换份额的input输入
        var inputStartTime = 0; //开始输入第一个数字的时间
        $(".couponListBox").on("input porpertychange", ".chooseNum input", function (event) {
            var maxchooseNum = $(this).attr("data-maxNum");
            var inputName = $(this).attr("data-classInputName");
            inputStartTime = event.timeStamp;
            var thisEvent = $(this);
            setTimeout(function () {
                if (inputStartTime - event.timeStamp == 0) {
                    var thisVal = parseInt(thisEvent.val());
                    if (thisVal < 1) {
                        thisVal = 1;
                    }
                    if (thisVal > maxchooseNum) {
                        thisVal = maxchooseNum;
                    }
                    thisEvent.val(thisVal);
                    setStroe($("." + inputName), thisVal);
                    clearChoose();
                    getChooseAbout();
                }
            }, 2000)
        });
        $(".couponListBox").on("click", "input[name='machineList']", function () {
            clearChoose();
            getChooseAbout();
        });
        //下拉刷新
        app.downRefresh(function () {
            clearChoose();
            var storeObj = app.getSyncStorage("changeMachineStore");
            var storePaymethod = JSON.parse(storeObj).paycurry;
            if (paymentCurrencyCode == storePaymethod) {
                chooseArrItem = JSON.parse(storeObj).chooseArrItem;
            }
            $(".couponListBox").empty();
            curPage = 1;
            totalPage = 0;
            couponList(account, curpage, paymentCurrencyCode, true);
        });
        // 监听滚动到底部 加载更多
        app.toBottom(function () {
            if (curpage < totalPage) {
                curpage++;
                couponList(account, curpage, paymentCurrencyCode, false);
            }
        });
        $(".submitButton").click(function () {
            // if (chooseValueAdd.chooseTotalBasePower > maxChangeNum) {
            //     var param = {
            //         dtype: "dialog12",
            //         data: {
            //             title: "提示",
            //             text: "已选择份额超过可置换额度"
            //         }
            //     };
            //     app.dialog(param);
            //     return
            // }
            var haveCheck = $("input[name=machineList]").is(":checked");
            if (haveCheck == false) return
            // console.log("---------------" + JSON.stringify({
            //     chooseArrItem: chooseArrItem,
            //     paycurry: paymentCurrencyCode
            // }));
            //监听普通矿机协议是否阅读
            app.setStorage("changeMachineStore", {
                chooseArrItem: chooseArrItem,
                paycurry: paymentCurrencyCode
            });
            //监听IPFS矿机协议是否阅读
            app.trigger("succefulChoose", {
                chooseArrItem: chooseArrItem,
                paycurry: paymentCurrencyCode,
                moneyNum: chooseValueAdd.unitTotalMoney
            })
            setTimeout(() => {
                app.closeW();
            }, 1000);
        })
        $("#aboutUsPage").click(function () {
            var param = {
                dtype: "dialog83"
            };
            app.dialog(param);
        })
        //监听导航栏选择
        app.headerMap(function (ret) {
            var param = {
                dtype: "dialog81"
            };
            app.dialog(param);
        });
        $(".chooseMessage").click(function () {
            $(".ipfsChangeText").slideToggle(100);
            if ($(this).find("img").hasClass("rotate")) {
                $(this).find("img").removeClass("rotate").addClass("rotatedeg");
            } else {
                $(this).find("img").removeClass("rotatedeg").addClass("rotate");
            }
        })
    }
</script>
<script type="text/html" id="couponListLi">
    {{~it:it:index}}
    <li>
        <div>
            <div class="machineName">
                <p>
                    <label for="chooseInput{{=index}}">
                        <input type="checkbox" class="chooseInputName{{=index}}" name="machineList" id="chooseInput{{=index}}" 
                        data-orderId="{{=it.orderId}}" 
                        data-unitMoney="{{=it.productDeposit}}"
                        data-chooseUnitMoney="{{=it.chooseUnitMoney}}"
                        data-basePower="{{=it.basePower}}" 
                        data-chooseBasepower="{{=it.chooseBasepower}}"
                        data-couputingPower="{{=it.computingPower}}" 
                        data-chooseCouPower="{{=it.chooseCouPower}}" 
                        data-bhpPower="{{=it.bhpPower}}" 
                        data-chooseBhppower="{{=it.chooseBhppower}}"
                        data-chooseNumber="{{=it.chooseNumber}}"
                        data-nameOptin="changeChoose{{=index}}"
                        {{?it.checkedInput}} checked {{?}}
                        >
                        <span class="machineText">
                            {{=it.productName}}
                        </span>
                    </label>
                </p>
                <p style="display: none;">
                </p>
            </div>
            <ul class="machineDetail">
                <li>
                    <p>
                        <span>
                            总金额
                        </span>
                        <span class="payMonenyNum">
                            {{=it.totalPrice}} <span style="font-size: 0.18rem;">{{=it.curryName}}</span>
                        </span>
                    </p>
                    <p>
                        <span>
                            基础算力
                        </span>
                        <span>
                            {{=it.totalBasePower}}T
                        </span>
                    </p>
                </li>
                <li>
                    <p>
                        <span>
                            总份额
                        </span>
                        <span>
                            {{=it.num}}份
                        </span>
                    </p>
                    <p>
                        <span>
                            BTC总算力
                        </span>
                        <span>
                             {{=it.totalComputingPower}}T
                        </span>
                    </p>
                </li>
                <li>
                    <p>
                        <span>
                            锁定到期
                        </span>
                        <span>
                            {{=it.endTime}}
                        </span>
                    </p>
                    <p style="display: none;">
                        <span>
                        </span>
                        <span>
                        </span>
                    </p>
                </li>
            </ul>
            <div class="changeChoose changeChoose{{=index}}" {{?!it.checkedInput}} style="display:none;" {{?}}>
                <p>
                    置换份额
                </p>
                <div>
                    <p class="chooseNum">
                        <span data-type="disButton" data-basePower="{{=it.basePower}}"  data-classInputName="chooseInputName{{=index}}" data-maxNum={{=it.num}} >
                            －
                        </span>
                        <input data-basePower="{{=it.basePower}}" data-classInputName="chooseInputName{{=index}}" type="text" name="chooseBtcNum" value="{{=it.chooseNumber}}" data-maxNum={{=it.num}}  >
                        <span data-type="addButton" data-basePower="{{=it.basePower}}" data-classInputName="chooseInputName{{=index}}" data-maxNum={{=it.num}}>
                            ＋
                        </span>
                    </p>
                </div>
            </div>
        </div>
    </li>
    {{~}}
</script>

</html>